package com.et114.components.simpletable;


import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * @author guanhw
 */
public class DisplayFooterTag extends TagSupport {
	private static final long serialVersionUID = -2606163390428100007L;
	private Log					logger				= LogFactory.getLog( this.getClass() );
	private String				style;
	private String				language			= "cn";
	private String				showSummary;
	private String				dataliststr			= "list";					
	private String				formName			= "testForm";				


	public int doEndTag() throws JspException {
		//HttpServletRequest request = ( HttpServletRequest ) super.pageContext.getRequest();
		JspWriter out = this.pageContext.getOut();
		if ( this.pageContext.getRequest().getAttribute( dataliststr ) == null ) {
			logger.error( "DisplayFooterTag:there is no datalist in request,please check" );
			return EVAL_PAGE;
		}
		DataList datalist = ( DataList ) pageContext.getRequest().getAttribute( dataliststr );
		String footer = "";
		FooterFactory factory = FooterFactory.getInstance( datalist , showSummary , formName ,language );
		footer = factory.getFooter( style );
		try {
			out.println( footer );
		} catch ( Exception e ) {
			logger.error(  e.getMessage() , e );
			throw new JspException( "Page Tag ERROR������ " , e );
		}
		return EVAL_PAGE;
	}

	public String getStyle ( ) {
		return style;
	}

	public void setStyle ( String style ) {
		this.style = style;
	}

	public String getShowSummary ( ) {
		return showSummary;
	}

	public void setShowSummary ( String showSummary ) {
		this.showSummary = showSummary;
	}

	public String getDataliststr ( ) {
		return dataliststr;
	}

	public void setDataliststr ( String dataliststr ) {
		this.dataliststr = dataliststr;
	}

	public String getFormName ( ) {
		return formName;
	}

	public void setFormName ( String formName ) {
		this.formName = formName;
	}


	public String getLanguage ( ) {
		return language;
	}

	public void setLanguage ( String language ) {
		this.language = language;
	}



}
